import { loadPlugin, loadPluginFn } from '../../app/config/loadplugin.config.js';
import authService from '../../app/resolves/authService.js';
import getCompanyList from '../resolves/getCompanyList.js';
import getCompanyDetail from '../resolves/getCompanyDetail.js';

import indexHtml from 'ngtemplate!html!../../../tpls/company/index.html';
import companyHtml from 'ngtemplate!html!../../../tpls/company/company.html';
import companyListHtml from 'ngtemplate!html!../../../tpls/company/company.list.html';
import companyviewHtml from 'ngtemplate!html!../../../tpls/company/company.view.html';


/**
 * AppConfig - config
 * 赛事模块路由设置
 */
CompanyRouter.$inject = ['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', '$ocLazyLoadProvider'];
function CompanyRouter($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider, $ocLazyLoadProvider) {

    //set router
    $stateProvider

        // 赛事主页
        .state('dashboard', {
            abstract: true,
            url: '/dashboard',
            data: { 
                pageTitle: '赛事主页' 
            },
            templateUrl: indexHtml,
            controller: 'DashboardController'
        })

        // 赛事机构注册
        .state('dashboard.company', {
            url: '/company/create',
            data: { 
                pageTitle: '赛事机构注册' 
            },
            templateUrl: companyHtml,
            controller: 'CompanyCreateController as vm',
            resolve: {
                authService: authService,
                loadPlugin: loadPluginFn([loadPlugin.icheck, loadPlugin.blink])
            }
        })

        // 赛事机构列表
        .state('dashboard.companylist', {
            url: '/company/list',
            data: { 
                pageTitle: '赛事机构列表' 
            },
            templateUrl: companyListHtml,
            controller: 'CompanyListController as vm',
            resolve: {
                authService: authService,
                getCompanyList: getCompanyList,
                loadPlugin: loadPluginFn([loadPlugin.grumble, loadPlugin.qrcode, loadPlugin.clipboard, loadPlugin.imglazy])
            }
        })

        // 查看赛事机构
        .state('dashboard.companyview', {
            url: '/company/view?company_id',
            data: { 
                pageTitle: '查看赛事机构' 
            },
            templateUrl: companyviewHtml,
            controller: 'CompanyViewController as vm',
            resolve: {
                authService: authService,
                getCompanyDetail: getCompanyDetail
            }
        })

        // 编辑赛事机构
        .state('dashboard.companyedit', {
            url: '/company/edit?company_id',
            data: { 
                pageTitle: '编辑赛事机构' 
            },
            templateUrl: companyHtml,
            controller: 'CompanyEditController as vm',
            resolve: {
                authService: authService,
                getCompanyDetail: getCompanyDetail,
                loadPlugin: loadPluginFn([loadPlugin.icheck, loadPlugin.blink])
            }
        });

}

export default CompanyRouter;